package com.karina.visualization.chart.client;

import java.util.List;

import com.karina.visualization.chart.component.CoordinateChart;
import com.karina.visualization.chart.component.CoordinateChartWidget;
import com.karina.visualization.chart.component.LineSeries;
import com.karina.visualization.chart.component.XAxis;
import com.karina.visualization.chart.model.CategorizedSeriesModel;
import com.karina.visualization.chart.model.LineChartModel;
import com.karina.visualization.chart.model.SeriesModel;
import com.karina.visualization.chart.skins.CoordinatePaneSkinImpl;

public class LineChartWidget<DataType> extends
		CoordinateChartWidget<LineChartModel<DataType>, DataType> {

	@SuppressWarnings("rawtypes")
	static class LineChart extends CoordinateChart {

		@SuppressWarnings({ "unchecked" })
		protected LineChart() {
			super(null, new CoordinatePaneSkinImpl(true));
		}

		@Override
		public String getSelectorName() {
			return "LineChart";
		}

		@Override
		protected Series createSeries(SeriesModel model) {
			return new LineSeries((CategorizedSeriesModel) model);
		}

		@Override
		protected void caculateChartObjectModelProperties() {
			super.caculateChartObjectModelProperties();
			XAxis xaxis = getXaxis();
			xaxis.getData().setStartFromZeroPoint(true);
		}

	}

	public LineChartWidget() {
		super(new LineChart());
	}

	@Override
	protected LineChartModel<DataType> createChartModel(
			List<DataType> dataProvider) {
		return new LineChartModel(dataProvider);
	}

}
